<?php

declare(strict_types=1);

namespace App\Request\User;

use App\Request\BaseCommonRequest;
use Hyperf\Context\Context;
use Hyperf\Validation\Request\FormRequest;

class EditFriendRequest extends BaseCommonRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'action' => 'required|in:index,edit',
            'want_age' => 'required',
            'want_place' => 'required',
            'want_height' => 'required',
            'want_education' => 'required',
            'want_income' => 'required',
            'want_weight' => 'required',
        ];
    }

    /**
     * 获取已定义验证规则的错误消息
     */
    public function messages(): array
    {
        $language = Context::get('language');
        if ($language == 'zh-cn') {
            return [
                'action.required' => '操作不能为空',
                'action.in' => '操作限定为：index,edit',
                'want_age.required' => '年龄必须',
                'want_place.required' => '地点必须',
                'want_height.required' => '身高必须',
                'want_education.required' => '学历必须',
                'want_income.required' => '收入必须',
                'want_weight.required' => '体重必须',
            ];
        } elseif ($language == 'zh-hk') {
            return [
                'action.required' => '操作不得為空',
                'action.in' => '操作限定為：index,edit',
                'want_age.required' => '年齡必須',
                'want_place.required' => '地點必須',
                'want_height.required' => '身高必須',
                'want_education.required' => '學歷必須',
                'want_income.required' => '收入必須',
                'want_weight.required' => '體重必須',
            ];
        } else {
            return [
                'action.required' => 'action.required',
                'action.in' => 'action is in index,edit',
                'want_age.required' => 'want_age is required',
                'want_place.required' => 'want_place is required',
                'want_height.required' => 'want_height is required',
                'want_education.required' => 'want_education is required',
                'want_income.required' => 'want_income is required',
                'want_weight.required' => 'want_weight is required',
            ];
        }

    }

}